$("#b1").click(function () {
    $(".m-item").toggleClass("m-mobile-hide");
});

$('.ui.dropdown').dropdown({
    on: 'hover'
})

function deleteEvent(button) {
    layer.confirm('确认要删除该活动吗？', function () {
        $.ajax({
            url: "/events/deleteEvents",
            data: {"eventsID": $(button).attr("data-id")},
            type: "delete",
            dataType: "json",
            async: false,   // 设置 Ajax 之间的同步（该同步会让Ajax锁住浏览器请求响应交互，保证每次请求被响应之后才释放浏览器）
            success: function (data) {
                if (data.code === 200) {
                    layer.msg('已删除!', {icon: 6, time: 1000});
                    //成功后定时刷新页面
                    setTimeout(() => location.replace(location.href), 1000);
                } else {
                    layer.msg('删除失败!', {icon: 5, time: 1000});
                    setTimeout(() => location.replace(location.href), 1000);
                }
            }
        });
    });
}

function PageRefresh() {
    window.location = window.location.pathname;
}

function topage(num) {
    // 获取关键字输入框的值，为其序列化，
    var keywords = $("input[name=keywords]").serialize();
    // 获取当前路径 URL 然后为路径 url 拼接关键字参数并重新提交
    window.location = window.location.pathname + "?" + keywords + "&pageNum=" + num;
}